package cn.glow.readingcloud.book.controller;


import cn.glow.readingcloud.book.service.BookService;
import cn.glow.readingcloud.common.result.Result;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import pojo.BookView;
import  cn.glow.readingcloud.common.pojo.Book;

/**
 * @Author Glow
 * @Date 2023-04-14 14:17:00
 * @Description 图书资源接口
 * @Version 1.0
 */
@Api("图书资源调度接口")
@RequestMapping("/book")
@RestController
public class BookController {
    @Autowired
    private BookService bookService;
    @ApiOperation(value = "查询图书基本信息" , httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "bookId", value = "图书ID", dataType = "String")
    })
    @ApiResponses({@ApiResponse(code = 200, message = "", response = Book.class)})
    @GetMapping("/getBookById")
    public Result<Book> getBookById(@RequestParam("bookId") String bookId){

        return bookService.getBookById(bookId);
    }
    @ApiOperation(value = "获取图书详情" , httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "bookId", value = "图书ID", dataType = "String")
    })
    @ApiResponses({@ApiResponse(code = 200, message = "", response = Book.class)})
    @GetMapping("/details")
    public Result<BookView> getBookDetails(String bookId){

        return bookService.getBookDetails(bookId);
    }

}
